package eight;

public class StaticVar {
    int a = 0; //实例变量
    static int b = 0; //静态变量
    StaticVar(){   //构造函数
        a++;
        b++;
    }
    void show(){
        System.out.println("a="+a+"，b="+b);
    }
}
class StaticDemo {
    public static void main(String[] args) {
        StaticVar o1 = new StaticVar();
        o1.show();
        StaticVar o2 = new StaticVar();
        o2.show();
        StaticVar o3 = new StaticVar();
        o3.show();
        System.out.println(StaticVar.b); //常常通过类名点来访问
    }
}
